package com.yycx.msg.provider.controller;

import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.utils.ApiAssert;
import com.yycx.msg.client.entity.MsgContent;
import com.yycx.msg.provider.service.MsgContentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author: zyf
 * @date: 2018/11/9 15:43
 * @description: 消息模块详情
 */
@Controller
@RequestMapping("/common")
public class MsgCommonController {

    @Autowired
    private MsgContentService msgContentService;

    /**
     * 获取服务协议
     */
    @GetMapping(value = "/msg/getById")
    public String getByCode(ModelMap map, Long msgId) {
        ApiAssert.isNotEmpty("参数不能为空", msgId);
        MsgContent msgContent = msgContentService.getById(msgId);
        if (FlymeUtils.isNotEmpty(msgContent)) {
            msgContent = new MsgContent();
        }
        map.addAttribute("msgContent", msgContent);
        return "message";
    }

}
